package com.zhouchj.elasticsearch.model.page;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author zhouchj
 * @date 2023/8/29
 */
public class PageEntity<T> implements IPage<T> {

    @JsonProperty("list")
    private List<T> records = Collections.emptyList();

    @JsonProperty("total")
    protected long total = 0L;

    @JsonProperty("pageIndex")
    protected long current = 1L;

    @JsonProperty("pageSize")
    protected long size = 10L;

    private List<OrderItem> orders = new ArrayList();

    public PageEntity() {
    }

    public PageEntity(long current, long size) {
        this.current = current;
        this.size = size;
    }

    public List<OrderItem> orders() {
        return this.getOrders();
    }

    public List<T> getRecords() {
        return this.records;
    }

    public IPage<T> setRecords(List<T> records) {
        this.records = records;
        return this;
    }

    public long getTotal() {
        return this.total;
    }

    public IPage<T> setTotal(long total) {
        this.total = total;
        return this;
    }

    public long getSize() {
        return this.size;
    }

    public IPage<T> setSize(long size) {
        this.size = size;
        return this;
    }

    public long getCurrent() {
        return this.current;
    }

    public IPage<T> setCurrent(long current) {
        this.current = current;
        return this;
    }

    public List<OrderItem> getOrders() {
        return this.orders;
    }

    public void setOrders(final List<OrderItem> orders) {
        this.orders = orders;
    }
}
